package com.mars.code.tools.vo;

import java.util.ArrayList;
import java.util.List;

public abstract class SqlCondition {
	
	private String field;
	private Object value;
	private Object value2;
	
	private boolean isListValue = false;
	private boolean isBetweenValue = false;
	
	List<String> conditions = new ArrayList<>();
	
	public SqlCondition eq(Object value) {
		conditions.add(" and " + field+"=");
		this.value=value;
		return this;
	}
	
	public SqlCondition neq(Object value) {
		conditions.add(" and " + field+"!=");
		this.value=value;
		return this;
	}

	public SqlCondition isNull(String field) {
		conditions.add(" and " + field+" is null");
		return this;
	}
	
	public SqlCondition isNotNull(String field) {
		conditions.add(" and " + field+" is not null");
		return this;
	}
	
	public SqlCondition gt(Object value) {
		conditions.add(" and " + field+">");
		this.value=value;
		return this;
	}
	
	public SqlCondition gte(Object value) {
		conditions.add(" and " + field+">=");
		this.value=value;
		return this;
	}
	
	public SqlCondition lt(Object value) {
		conditions.add(" and " + field+"<");
		this.value=value;
		return this;
	}
	
	public SqlCondition lte(Object value) {
		conditions.add(" and " + field+"<=");
		this.value=value;
		return this;
	}
	
	public SqlCondition in(Object[] values) {
		conditions.add(" and " + field+" in ");
		this.value=values;
		this.isListValue = true;
		return this;
	}
	
	public SqlCondition notIn(Object[] values) {
		conditions.add(" and " + field+" not in ");
		this.value=values;
		this.isListValue = true;
		return this;
	}
	
	public SqlCondition between(Object min, Object max) {
		conditions.add(" and " + field+" between ");
		this.value=min;
		this.value2=max;
		isBetweenValue = true;
		return this;
	}
	
	public SqlCondition notBetween(Object min, Object max) {
		conditions.add(" and " + field+" not between ");
		this.value=min;
		this.value2=max;
		isBetweenValue = true;
		return this;
	}
	
}

class FieldCondition {
	private String field;
	private Object value;
	private Object value2;
	
	private boolean isListValue = false;
	private boolean isBetweenValue = false;
	public String getField() {
		return field;
	}
	public void setField(String field) {
		this.field = field;
	}
	public Object getValue() {
		return value;
	}
	public void setValue(Object value) {
		this.value = value;
	}
	public Object getValue2() {
		return value2;
	}
	public void setValue2(Object value2) {
		this.value2 = value2;
	}
	public boolean isListValue() {
		return isListValue;
	}
	public void setListValue(boolean isListValue) {
		this.isListValue = isListValue;
	}
	public boolean isBetweenValue() {
		return isBetweenValue;
	}
	public void setBetweenValue(boolean isBetweenValue) {
		this.isBetweenValue = isBetweenValue;
	}
	
}
